package org.game.common.Resourse
{
	import flash.display.Loader;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.net.URLRequest;
	
	
	/**
	 * @author 缺硒
	 */
	public class GameLoader extends Loader
	{
		private var _index:int;
		private var _callFunc:Function;
		
		public function GameLoader()
		{
		}
		
		/**
		 * 加载资源
		 * @param url
		 * @param onComplete 
		 */		
		public function loadElement(url:String, callFunc:Function):void
		{
			_callFunc = callFunc;
			contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
			contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
			load(new URLRequest(url));
		}
		
		//加载 成功
		private function onComplete(evt:Event):void
		{
			if(_callFunc != null)
				_callFunc.apply(null, [this]);
		}
		
		
		//加载出错
		private function onError(evt:IOErrorEvent):void
		{
			trace("加载失败：",evt.text)
		}

		/**
		 * 获取回调
		 * @return  
		 */		
		public function get callFunc():Function
		{
			return _callFunc;
		}

	}
	//
}